<?php
header("Content-type: text/html; charset=utf-8");
require("inc/common.inc.php");
if (trim($weizhix)!="" and trim($weizhiy)!="" and trim($_COOKIE["mxadminwx"]["wxmxopenid"])!=""){
	if (!is_numeric($weizhix) or !is_numeric($weizhiy)){exit();}
	//判断用户是否存在
	$vpp_user_info=$db->getinfo("select * from mx_user where weixinid='$wxmxopenid' limit 1");
	if (!is_array($vpp_user_info)){exit();}
	
	//获取地理位置
	$aa=get_maps_addinfo($weizhix,$weizhiy);
	$province=$aa[province];
	$city=$aa[city];
	$district=$aa[district];
	$address=$aa[address];
	if(date("Y-m-d",strtotime($vpp_user_info["lastlogintime"]))!=date("Y-m-d")){
		//判断是否当天第一次登陆
		$db->excu("update mx_user set weizhix='$weizhix',weizhiy='$weizhiy',province='$province',city='$city',district='$district',address='$address',mapupdate='".date("Y-m-d H:i:s")."',logindays=logindays+1,logintimes=logintimes+1,lastlogintime='".date("Y-m-d H:i:s")."' where id='$vpp_user_info[id]'");
	}
	//elseif (time()-strtotime($vpp_user_info["lastlogintime"])>=1800 or time()-strtotime($vpp_user_info["mapupdate"])>=1800){
	else{
		//只更新最后坐标
		$db->excu("update mx_user set weizhix='$weizhix',weizhiy='$weizhiy',province='$province',city='$city',district='$district',address='$address',mapupdate='".date("Y-m-d H:i:s")."',lastlogintime='".date("Y-m-d H:i:s")."' where  id='$vpp_user_info[id]'");
	}
	//$db->excu("insert into mx_vpp_maplog (userid,weizhix,weizhiy,province,city,district,adddate) values ('$id','$weizhix','$weizhiy','$province','$city','$district','".date("Y-m-d H:i:s")."')");

}
?>